<?php
namespace Admin\Controller;
use Common\Controller\BaseController;
class PublicController extends BaseController{

	//登录页面
	public function login(){	
	 	session("uid")?$this->redirect('Index/index'):$this->display();
	}

	//登入
	public function checkin(){
	$this->checkCode();
		
    $oop=M('member');
	$map['account'] = I('username');
	$map['status']=1;
	$authInfo = $oop->where($map)->find();

        //使用用户名、密码和状态的方式进行认证
        if(!$authInfo || $authInfo['password'] != md5(I('password').$authInfo['salt']))
				$this->error(L("error_pwd"));
	
	session("uid",$authInfo['id']);					
	//dump($_SESSION);exit;
	$authInfo['last_login_time']=date('Y-m-d H:i:s');
	$authInfo['last_login_ip']=get_client_ip();
	$authInfo['login_count']++;
	$oop->save($authInfo);
    $this->success(L("checkin_success"));
	
	}
	
	//登出
	public function logout(){
		session(null);
		$this->success(L("checkout_success"),U('Public/login'));
	}
	

}
?>